/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2021年6月6日
 */
package com.massyframework.beanskin.assembly;

import java.util.Collection;

import com.massyframework.beanskin.service.DependencyServiceDescriptor;
import com.massyframework.beanskin.service.ServiceReference;

/**
 * 依赖匹配器，提供装配件依赖匹配的情况，包括：
 * <ul>
 * <li>是否全部依赖都已经匹配</li>
 * <li>所有未匹配的依赖服务描述</li>
 * <li>根据依赖服务描述获取对应的服务引用</li>
 * </ul>
 * 
 * <p>
 * 使用方式：通过{@link Assembly#adapt(Class)}方法获取对应装配件的依赖匹配器实例。
 * <pre>
 * DependencyMatcher matcher = assembly.adapt(DependencyMatcher.class);
 * if (matcher != null){
 *    // TODO Implements 
 * }
 * </pre>
 * 
 * @author huangkh
 */
public interface DependencyMatcher {

	/**
     * 获取匹配依赖服务描述的服务引用
     * @param descriptor 依赖服务描述
     * @return {@link ServiceReference},如果依赖服务未被匹配，则可能返回null.
     */
    <S> ServiceReference<S> findMatchedServiceReference(DependencyServiceDescriptor<S> descriptor);

    /**
     * 所有未匹配的依赖服务描述
     * @return {@link List}, 依赖服务描述集合
     */
    Collection<DependencyServiceDescriptor<?>> getUnmatchDependencyServiceDescriptors();

    /**
     * 是否所有的依赖都已经匹配
     * @return {@link boolean},返回<code>true</code>表示全部匹配，否则返回<code>false</code>
     */
    boolean isAllMatched();
}
